/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2010.

	This file is part of Maxsi Distribution.

	Maxsi Distribution is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi Distribution is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
	or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
	License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Distribution. If not, see <http://www.gnu.org/licenses/>.

	Maxsi Distribution
	A powerful digital distribution library designed for games and software.

	MD_Release.h
	A system that allows you to release product data to master servers and
	several content servers.

******************************************************************************/

#ifndef MD_Release_H
#define MD_Release_H

#define MD_RELEASE_EVENT_NONE 0
#define MD_RELEASE_EVENT_ERROR 1
#define MD_RELEASE_EVENT_SCAN 2
#define MD_RELEASE_EVENT_SHA1 3
#define MD_RELEASE_EVENT_COMPRESS 4
#define MD_RELEASE_EVENT_UPLOAD 5
#define MD_RELEASE_EVENT_MASTERING 6
#define MD_RELEASE_EVENT_FINISHED 7

typedef MaxsiError (*MD_ReleaseCallback)(BYTE* UserData, MaxsiInterface* Caller, MaxsiHandle ReleaseHandle, int EventType, int Parameter, float Progress);

#if 0
MD_STRUCTLINK MD_ReleaseInformation
{
	MD_ReleaseCallback Callback;
	BYTE* UserData;
	MESTR* ContentArchive;
	MESTR** MasterServers;
	size_t NumMasterServers;
	MESTR** ContentServers;
	size_t NumContentServers;
	MESTR* MasterImagePath;
};
#endif

MD_CLASSLINK MD_Release
{
public:
	MD_ReleaseCallback Callback;
	BYTE* UserData;
	MESTR* ContentArchive;
	MESTR** MasterServers;
	size_t NumMasterServers;
	MESTR** ContentServers;
	size_t NumContentServers;
	MESTR* MasterImagePath;
	MaxsiInterface* Caller;
	List FileList;
	List BlockHashList;
	List FileHashList;
	FileSize_t TotalFileSize;
	size_t BlockSize;
	FileSize_t NumBlocks;
	BYTE* FileListString;

public:
	MD_Release();
	~MD_Release();

protected:
	virtual void SignalProgress(int Event, int Parameter = 0, float Progress = 0.0f);
	virtual MaxsiError ScanDir(MESTR* AbsPath, MESTR* RelPath);
	virtual MaxsiError CalculateFileHashes();
	virtual MaxsiError CalculateFileList();
	virtual MaxsiError UploadFileList();
	virtual MaxsiError UploadBlocks();
	
public:
	virtual MaxsiError Release();
	virtual MaxsiError ReleaseProduct();
	virtual MaxsiError ReleaseProductSHA();
	virtual MaxsiError ReleaseProductUpload();

};

#endif

